<#include "./_material_submenu.ftl">

<#macro sideMenu>
    <h4 class="centered">${i18n.material.sidebarHeader!"Матеріали курса"}</h4>
    <hr/>
    <#-- Course Home -->
    <#if (courseId?has_content && courseId > 0)>
        <div style="padding: 8px 15px; border-top: 1px solid #E5E5E5;">
            <a href="${baseUrl}/material/?course_id=${courseId}">
                <i class="icon-info-sign"></i>&nbsp;
                ${i18n.material.courseHome!"Інформація про курс"}
            </a>
        </div>
    </#if>

    <#assign currentSectionTitle = "xxx">
    <div class="accordion" id="accordion2">
        <div class="accordion-group">
            <#assign collapseNum = 0>
            <#list materials_titles as section_title>
                <#-- Empty section title, output material title without accordion. -->
                <#if section_title.getSectionTitle()?string == "">
                    <div style="padding: 8px 15px;">
                        <a href="${baseUrl}/material/view/?material_id=${section_title.getId()}">${section_title.getTitle()}</a>
                    </div>
                </#if>
                <#if (currentSectionTitle != section_title.getSectionTitle()?string && section_title.getSectionTitle()?string != "")>
                    <div class="accordion-heading">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
                            href="#collapse${collapseNum}">
                            ${section_title.getSectionTitle()}
                        </a>
                    </div>
                    <div id="collapse${collapseNum}" class="accordion-body collapse <#if (currentCollapseNum?has_content && collapseNum == currentCollapseNum)>in</#if>">
                        <div class="accordion-inner">
                            <ul>
                            <#list materials_titles as title>
                                <#if (section_title.getSectionTitle() == title.getSectionTitle())>
                                    <li class="<#if (materialId?has_content && title.getId() == materialId)>active</#if>">
                                        <a href="${baseUrl}/material/view/?material_id=${title.getId()}&si=${collapseNum}">${title.getTitle()}</a>
                                    </li>
                                    <#if hwList?has_content && loggedOnUser?has_content && isEnrolled>
                                        <#assign hwCounter = 1>
                                        <#list hwList as hwork>
                                            <#if hwork?has_content && (hwork.getMaterialId() == title.getId())>
                                                <li class="sidebar-homework">
                                                    <i class="icon-time"></i>&nbsp;
                                                    <small>
                                                        <a href="${baseUrl}/homework/view/?homework_id=${hwork.getId()}&si=${collapseNum}">
                                                            ${hwork.getHomeWorkTitle()}
                                                        </a><br/>
                                                        ${i18n.material.homework_expire_text}&nbsp;${hwork.getDueDate()}
                                                    </small>
                                                </li>
                                            </#if>
                                            <#assign hwCounter = hwCounter + 1>
                                        </#list>
                                    </#if>
                                </#if>
                            </#list>
                            </ul>
                        </div>
                    </div>
                    <#assign collapseNum = (collapseNum + 1)>
                </#if>
                <#assign currentSectionTitle = section_title.getSectionTitle()>

            </#list>
            <div style="padding: 8px 15px; border-top: 1px solid #E5E5E5;">
                <a href="${syllabusLink}">
                    <i class="icon-download"></i>&nbsp;
                    ${i18n.material.syllabus!"План"}
                </a>
            </div>
            <#if loggedOnUser?has_content && isEnrolled>
            <div style="padding: 8px 15px; border-top: 1px solid #E5E5E5;">
                <a href="${baseUrl}/course/svn/?course_id=${courseId}">
                    <i class="icon-lock"></i>&nbsp;
                    ${i18n.material.svn_a_label!"Доступ до SVN"}
                </a>
            </div>
            </#if>
        </div> <#-- accordion-group -->
    </div> <#-- accordion -->
</#macro>


<#-- Empty material in some cases this is possible. -->
<#macro emptyMaterialModal>
<#--Modal -->
<div class="modal" id="emptyMaterialModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">${i18n.material.noMaterialFoundTitle!"No materials found."}</h3>
    </div>
    <div class="modal-body">
        <p>${i18n.material.noMaterialFoundBody!"No materials found yet. Please feel free to come back soon for an updates."}</p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Закрыть</button>
    </div>
</div>
</#macro>
